package com.ruoyi.lvlian.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.lvlian.dto.NoticeDto;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.lvlian.domain.Notice;
import com.ruoyi.lvlian.service.INoticeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 政策文件Controller
 *
 * @author ruoyi
 * @date 2025-07-04
 */
@Api(value = "政策文件", tags = "政策文件Controller")
@RestController
@RequestMapping("/notice")
public class NoticeController extends BaseController {
    @Autowired
    private INoticeService noticeService;

    /**
     * 查询政策文件列表
     */
//    @RequiresPermissions("lvlian:notice:list")
    @GetMapping("/list")
    public TableDataInfo list(NoticeDto notice) {
        startPage();
        List<Notice> list = noticeService.selectNoticeList(notice);
        return getDataTable(list);
    }



    /**
     * 获取政策文件详细信息
     */
//    @RequiresPermissions("lvlian:notice:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(noticeService.selectNoticeById(id));
    }

    /**
     * 修改政策文件
     */
//    @RequiresPermissions("lvlian:notice:edit")
    @Log(title = "政策文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Notice notice) {
        return toAjax(noticeService.updateNotice(notice));
    }

    /**
     * 删除政策文件
     */
//    @RequiresPermissions("lvlian:notice:remove")
    @Log(title = "政策文件", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(noticeService.deleteNoticeByIds(ids));
    }
}
